/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.comandos.supervisor;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.model.Administrador;
import br.ufc.quixada.adrs.model.Supervisor;
import br.ufc.quixada.adrs.service.AdministradorService;
import br.ufc.quixada.adrs.service.SupervisorService;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Franklin
 */
public class CmdListarAdministradores implements Comando{

    public String executa(HttpServletRequest request, HttpServletResponse response) {
        

    HttpSession session = request.getSession(true);
    Supervisor supervisor = (Supervisor) session.getAttribute("user");
    SupervisorService supervisorService = new SupervisorService();

    AdministradorService administradorService = new AdministradorService();
    
    List<Administrador> administradores = administradorService.getAllAdministradores();

    session.setAttribute ("administradores", administradores);

        //ELIMINANDO DADOS CADASTRAIS DA SESSÃO
        
        session.removeAttribute("nome");
        session.removeAttribute("apelido");
        session.removeAttribute("rg");
        session.removeAttribute("cpf");
        session.removeAttribute("contato1");
        session.removeAttribute("contato2");
        session.removeAttribute("email");
        session.removeAttribute("localidade");
        session.removeAttribute("login");
        session.removeAttribute("estado");
        session.removeAttribute("municipio");
        
        return "/supervisor/supervisor_gerenciar_administradores.jsp";
    }




}
